package com.imooc.socketexample;

import java.io.*;
import java.net.ServerSocket;
import java.net.Socket;

/**
 * Created by yijy on 2017/11/9.
 */
public class Server {
    public static void main(String[] args) throws IOException {
        ServerSocket serverSocket = new ServerSocket();
        Socket socket = serverSocket.accept();
    }

    public void login(Socket socket){
        OutputStream os = null;
        try {
            InputStream is = socket.getInputStream();
            BufferedReader br = new BufferedReader(new InputStreamReader(is));
            String info="";
            while ((info=br.readLine())!=null){
                System.out.println(info);
            }
            socket.shutdownInput();
            os = socket.getOutputStream();
            PrintWriter pw = new PrintWriter(os);
            if("admin".equals(info)){
                pw.print("welcome in server!");

            }else{

            }
            pw.flush();

        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
